<?php

namespace app\admin\model;

use think\Model;


class Sign extends Model
{





    // 表名
    protected $table = 'sign';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text'
    ];



    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    //返回月份的日期号
    public static function getMonthDate($month){
        $m_start_date = date("Y-m-d",strtotime($month));
        $m_end_date = date("Y-m-d",strtotime(date("Y-m",strtotime("+1 month",strtotime($month))))-1);
        $start_time = strtotime($m_start_date);
        $end_time = strtotime($m_end_date);
        $date_list = [];
        for ($i= $start_time;$i<=$end_time;$i+=86400){
            $date_list[]= date("Y-m-d",$i);
        }
        return $date_list;
    }




}
